<style>
#ui-datepicker-div.ui-widget-content{background: #fff;border: 1px solid gray;}
table{text-align: left;width: 100%;}
table tr th{background-color: #eeeeee;}
table tr td,table tr th{border: 1px solid #d3d2d2;padding: 5px;}
table input{width: 80px;height: 20px;}

table label{display: inline-block;cursor: default;margin: 0 3px;}
table input[type="checkbox"],table input[type="radio"]{margin: 0;cursor: default;margin-top: -2px;}
table .thSetPrice a{
	display: block;margin: 5px 0;padding: 3px 5px;border: 1px solid #888888;background-color: #888888;
	color: #fff;text-decoration: none;text-align: center;width: 60px;cursor: pointer;
}
table a:hover{text-decoration: none;background-color: #368ee0;border-color: #368ee0;}

.page{padding: 5px;border: 2px solid #368ee0;border-top: none;}
.page .page_count{padding-top: 5px;}
.page .page_count label{display: inline-block;line-height: 30px;font-weight: normal;float: left;}
.page .page_count .paginate_button{
	margin: 0 5px;
	float: left;
	background-color: #D5D5D5;
	padding: 5px 12px;
	color: #7d7d7d;
	border-radius: 3px;
}
.page .page_count .paginate_button:hover{
	background-color: #89affc;
	color: #fff;
}
.page .page_count .paginate_active{
	margin: 0 5px;
	float: left;
	padding: 5px 12px;
	color: #fff;
	background-color: #89affc;
	border-radius: 3px;
}
.page a{text-decoration: none;}
table tbody tr.thPor:hover{background-color: #D9D9D9;}
.ui-datepicker-trigger{display: none;}

#pop-up-boxes{
    position: fixed;width: 100%;height: 100%;z-index: 20;top: 0;left: 0;display: none;
}
#pop-up-boxes-iiiii{
    position: fixed;width: 100%;height: 100%;display: block;background-color: #303030;z-index: -1;top: 0;left: 0;
    filter:alpha(opacity=70);-moz-opacity:0.7;-khtml-opacity: 0.7;opacity: 0.7;
}
#pop-up-boxes-content{
    width: 500px;font-size: 14px;margin: 10% auto;overflow: hidden;
    border: 1px solid black;color: black;background-color: #fff;border-radius: 10px;
}
#pop-up-boxes-title label{display: inline-block;}
#pop-up-boxes-title img{
    float: right;left: 0;top: 17px;width: 16px;height: 16px;margin: 3px;border: none;border-radius: 10px;cursor: pointer;
}
#pop-up-boxes-text{padding: 20px;text-align: center;color: #555555;}
#pop-up-boxes-text input,#pop-up-boxes-text select{width: 100px;padding: 3px;}
#pop-up-boxes-text button{padding: 3px 10px;border: 1px solid #46b8da;background-color: #46b8da;color: #fff;border-radius: 3px;margin-top: -10px;margin-left: 30px;}
#pop-up-boxes-text div{max-height: 300px;overflow-y:auto;}
#pop-up-boxes-text div::-webkit-scrollbar{width: 2px;}
#pop-up-boxes-text div::-webkit-scrollbar-thumb{background-color: rgba(50,50,50,0.3);}

#pop-up-boxes table thead tr th{border-bottom: none;}
#pop-up-boxes-text table thead tr th,#pop-up-boxes-text table tbody tr td{width: 25%;text-align: center;border: 1px solid #d3d2d2;font-weight: 500;}
</style>
<div id="main">
    <div class="container-fluid">
        <div class="page-header">
        	<div class="pull-left">
        		<h1>佣金加浮管理</h1>
        	</div>
        	<div class="pull-right">
        		<ul class="stats">
        			<li class='lightred'>
        				<i class="icon-calendar"></i>
        				<div class="details">
        					<span class="big"></span>
        					<span></span>
        				</div>
        			</li>
        		</ul>
        	</div>
        </div>
        <div class="breadcrumbs">
        	<ul>
        		<li>
        			<a href="javascript:void(0);">后台管理</a>
        			<i class="icon-angle-right"></i>
        		</li>
        		<li>
        			<a href="javascript:void(0);">佣金浮动管理</a>
        			<i class="icon-angle-right"></i>
        		</li>
        		<li>
        			<a href="javascript:void(0);">浮动列表</a>
        		</li>
        	</ul>
        	<div class="close-bread">
        		<a href="#"><i class="icon-remove"></i></a>
        	</div>
        </div>
        <div class="row-fluid">
        	<div class="span12">
        		<div class="box box-color box-bordered">
        			<div class="box-title">
        				<h3>
        					<i class="icon-th-list"></i>
        					浮动列表
        				</h3>
        			</div>
                    <div style="border: 2px solid #368ee0;border-top: none;border-bottom: none;padding: 10px;">
                        <form action="" method="get" style="margin: 0;padding: 0;">
                            关键字 <input type="text" name="nameKey" value="<?=$nameKey?>" placeholder="酒店名称,房型名称(多个用半角逗号分开)" style="margin-top: 5px;width: 300px;" />
                            <button style="border: 1px solid transparent;background-color: #368ee0;color: #fff;padding: 3px 8px;margin-top: -5px;">查询</button>
                            <a href="<?=$this->url('mySetPrice/index')?>" style="color: red;margin-left: 10px;">显示全部</a>
                        </form>
                    </div>
                    <div style="border: 2px solid #368ee0;border-top: none;<?=$number>1?'border-bottom: none;':''?>">
                        <link rel="stylesheet" href="/public/assets/sysadmin/mylzp/css/jquery-ui.css">
                        <script type="text/javascript" src="/public/assets/sysadmin/mylzp/js/jquery-ui.js"></script>
                        <table>
        					<thead>
        						<tr>
        							<th>所属酒店</th>
        							<th>房型</th>
        							<th>底价(元)</th>
        							<th>时间选择</th>
        							<th width="40%">渠道选择</th>
        							<th>浮动价格</th>
                                    <th width="70px">操作</th>
        						</tr>
        					</thead>
                            <tbody>
							<?
							if($re){
								foreach($re as $k=>$v){
									?>
									<tr class="thPor">
										<form action="<?=$this->url('mySetPrice/upSetPrice')?>" method="post" id="updata<?=$k?>" class="form-horizontal form-bordered form-validate" >
											<input type="hidden" name="hotelId" value="<?=$v['hotelId']?>" />
											<input type="hidden" name="parentTypeId" value="<?=$v['parentTypeId']?>" />
											<input type="hidden" name="typeId" value="<?=$v['id']?>" />
											<td><?=$v['hotelName']?></td>
											<td><?=$v['title']?></td>
											<td><?=$v['price']?></td>
											<td>
												<input type="text" name="sta" value="<?=date('Y-m-d',time())?>" placeholder="开始时间" class="datepickerinput" readonly="" />
												-
												<input type="text" name="end" value="" class="datepickerinput" placeholder="结束时间" readonly="" />
											</td>
											<td>
											<?
												foreach($v['channels'] as $ka=>$va){?>
												   <label><input type="checkbox" name="channels[]" value="<?=$va['osiiId']?>" /> <?=$va['title']?></label>
												<?}
											?>
											</td>
											<td>
												<label><input type="radio" name="fudong" value="1" />加浮</label>
												<label><input type="radio" name="fudong" value="2" />减浮</label><br />
												<input type="text" name="setprice" value="" />
											</td>
											<td class="thSetPrice">
												<a href="javascript:;" class="show_shadefrist" onclick="setPrice('<?=$k?>')">确认浮动</a>
												<a href="javascript:;" onclick="fudongLog('<?=$v['hotelId']?>','<?=$v['parentTypeId']?>','<?=$v['id']?>','<?=$v['hotelName'].'--'.$v['title']?>','','',0)">浮动记录</a>
											</td>
										</form>
									</tr>
									<?
								}
							}else{?>
								<tr><td colspan="7" style="text-align: center;font-size: 20px;">没有相关记录</td></tr>
							<?}
							?>
                            </tbody>
        				</table>
                    </div>
                    <?if($re&&$number>1){?><div class="page"><?=$pageHtml?></div><?}?>
        		</div>
        	</div>
        </div>
    </div>
</div>
<div id="pop-up-boxes">
    <div id="pop-up-boxes-iiiii"></div>
    <div id="pop-up-boxes-content">
        <div id="pop-up-boxes-title"><label style="margin-left: 10px;"></label><img src="/public/assets/sysadmin/mylzp/img/error.png" /></div>
        <div id="pop-up-boxes-text">
			起始时间：<input type="text" name="sta" class="datepickerinput" value="" readonly="" />
			-
			<input type="text" name="end" class="datepickerinput" value="" readonly="" /><br /><br />
			渠道：<select name="channelsId">
			<option value="0">全部</option>
			<?
			if($channels){
				foreach($channels as $k=>$v){?>
					<option value="<?=$v['osiiId']?>" ><?=$v['title']?></option>
				<?}
			}
			?>
			</select>
			<input type="hidden" name="hotelId" value="" />
			<input type="hidden" name="typeId" value="" /><input type="hidden" name="parentTypeId" value="" />
			<button>搜 索</button><br /><br />
            <table>
                <thead>
                    <tr><th>日期</th><th>浮动金额(元)</th><th>渠道</th><th>操作时间</th></tr>
                </thead>
            </table>
			<div>
				<table>
					<tbody id="show_logs">
						
					</tbody>
				</table>
			</div>
        </div>
    </div>
</div>
<script type="text/javascript">
$('#pop-up-boxes-title img').click(function(){
    $('#pop-up-boxes').hide();
});
$(function() {
	$(".datepickerinput").datepicker({
        minDate: 0,
        showMonthAfterYear: true,
        changeMonth: true,
        numberOfMonths: 1,
        showOn: "both",
        showButtonPanel:true,
        duration: 100,
		buttonImageOnly: false,
        onSelect: function( selectedDate ) {
            $(this).next().next().datepicker( "option", "minDate", selectedDate );
        }
    });
});

$('#pop-up-boxes-text button').click(function(){
	var hotelId=$('#pop-up-boxes-text input[name="hotelId"]').val();
	var parentTypeId=$('#pop-up-boxes-text input[name="parentTypeId"]').val();
	var typeId=$('#pop-up-boxes-text input[name="typeId"]').val();
	var titleName=$('#pop-up-boxes-title label').html();
	var sta=$('#pop-up-boxes-text input[name="sta"]').val();
	var end=$('#pop-up-boxes-text input[name="end"]').val();
	var channelsId=$('#pop-up-boxes-text select[name="channelsId"]').val();
	fudongLog(hotelId,parentTypeId,typeId,titleName,sta,end,channelsId);
});

function fudongLog(hotelId,parentTypeId,typeId,titleName,sta,end,channelsId){
    $.ajax({
		type:'POST',
		url:'<?=$this->url("mySetPrice/showLog")?>',
		data:'hotelId='+hotelId+'&parentTypeId='+parentTypeId+'&typeId='+typeId+'&sta='+sta+'&end='+end+'&channelsId='+channelsId,
		dataType:'json',
		success:function(r){
            if(r.state==1){
				$('#pop-up-boxes-title label').html(titleName);
				$('#pop-up-boxes-text input[name="hotelId"]').val(r.hotelId);
				$('#pop-up-boxes-text input[name="parentTypeId"]').val(r.parentTypeId);
				$('#pop-up-boxes-text input[name="typeId"]').val(r.typeId);
				$('#pop-up-boxes-text input[name="sta"]').val(r.sta);
				$('#pop-up-boxes-text input[name="end"]').val(r.end);
				$('#pop-up-boxes-text select[name="channelsId"]').find("option[value="+r.channelsId+"]").attr("selected",true);
				$('#pop-up-boxes').show();
                $('#show_logs').html(r.html);
				$('#pop-up-boxes-text table tbody tr').hover(function(){
					$(this).css({'background-color':'#D9D9D9c'});
				},function(){
					$(this).css({'background-color':'#fff'});
				});
            }else{
                pub_alert_error(r.html,2000);
            }
		},
        error:function(){
            pub_alert_error("ajax出现错误",2000);
        }
	});
}
function setPrice(key){
    $('#updata'+key).submit();
}
</script>